package com.base.system.enums;

public enum HttpStatus {
    success(200, "操作成功"),
    faild(100, "操作失败"),
    forbidden(403, "权限不足"),
    bad_error(500, "服务器内部错误"),
    format_error(999, "格式错误"),
    yzm_error(901, "验证码错误"),
    token_expired(902, "凭证已失效"),
    acount_error(903, "账户信息错误");

    private String note;
    private Integer code;

    HttpStatus(int code, String note) {
        this.code = code;
        this.note = note;
    }

    public String getNote() {
        return note;
    }

    public Integer getCode() {
        return code;
    }

    public static String getNoteByCode(Integer code) {
        for (HttpStatus value : HttpStatus.values()) if (value.getCode().equals(code)) return value.getNote();
        return null;
    }

    public static HttpStatus getObjByCode(Integer code) {
        for (HttpStatus value : HttpStatus.values()) if (value.getCode().equals(code)) return value;
        return null;
    }
}
